package org.Niu;

import java.util.Calendar;
import java.util.Date;

public class CalendarTime {
    public static void main(String[] args) {
        // 1. 创建
        Calendar calendar = Calendar.getInstance();

        // 2. Get
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH) + 1;
        int date = calendar.get(Calendar.DATE);
        System.out.println(year + "年" + month + "月" + date + "日");
        Date time1 = calendar.getTime();

        // 3. Set
        calendar.set(Calendar.DATE,31);

        year = calendar.get(Calendar.YEAR);
        month = calendar.get(Calendar.MONTH) + 1;
        date = calendar.get(Calendar.DATE);
        System.out.println(year + "年" + month + "月" + date + "日");

        // 4. add
        calendar.add(Calendar.DATE,-3);
        year = calendar.get(Calendar.YEAR);
        month = calendar.get(Calendar.MONTH) + 1;
        date = calendar.get(Calendar.DATE);
        System.out.println(year + "年" + month + "月" + date + "日");
        Date time2 = calendar.getTime();

        System.out.println(time1);
        System.out.println(time2);




    }
}
